import {reqGetSongUrl,reqGetSongDetail} from "@/api/player"
const GET_SONG_URL = "GET_SONG_URL"
const SET_PLAY_PAUSE ="SET_PLAY_PAUSE"
 
export default {
  namespaced:true,
  state:{
    // 歌曲id
    songId:null,
    // // 歌曲名称
    // songName:null,
    // // 歌曲url
    // songUrl:null,
    // // 歌曲图片
    // songImg:null

    // 是否开始音频播放组件
    isPlay:false,
    // 歌曲url信息
    songUrlList:[],
    // 歌曲详情信息
    songDetailList:[]
  },
  actions:{
    // 发送请求获取歌曲url和歌曲详情
    async getSong({commit},id){
      const [{data},{songs}] = await Promise.all([reqGetSongUrl(id),reqGetSongDetail(id)])
      commit(GET_SONG_URL,{id,data,songs})
    }
  },
  mutations:{
    [GET_SONG_URL](state,{id,data,songs}){
      state.songUrlList = data
      state.songDetailList = songs
      state.isPlay = true
      state.songId = id
    },
    [SET_PLAY_PAUSE](state){
      const {isPlay} = state
      state.isPlay = !isPlay
    }
  },
  getters:{

  }
}